
#include "main.h"
#include "armsdkerr.h"
#include "armsdkcmdhandle.h"
#include "armsdkglob.h"
#include "armsdkcli.h"
#include "armsdkcmdterm.h"
#include "uartcli.h"


INT4 main(void)
{
    INT4 i4Ret = 0;
    INT4 i4Cnt = 0;
    CHR u1InputChr;
    CHR au1CmdStr[CMD_WORD_LEN] = {0};

    adSDKCmdRegister();
    uartSDKCmdRegister();

    set_unbuffered_input();

    PRINTF("%s", ARM_DEV_SDK_INFO);

    while(TRUE)
    {
        ARM_CMD_PROMPT();
        ARM_CMD_INPUT(&u1InputChr, au1CmdStr, &i4Cnt);

        if ( u1InputChr != '\n')
        {
            continue;
        }

        /* if input null, do nothing */
        if (au1CmdStr[0] == '\0')
        {
            continue;
        }

        i4Ret = adAPISdkCmdHandle(au1CmdStr);
        if (i4Ret == EXIT)
        {
            break;
        }

        i4Cnt = 0;
        MEMSET(au1CmdStr, 0, CMD_WORD_LEN);
    }

    reset_terminal();

    return SUCCESS;
}

